﻿using System;
using System.Collections.Generic;
using System.IO;
using Windows.UI.Xaml.Media.Imaging;
using System.Linq;
using System.Windows.Input;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Input;
using Windows.UI.Core;
using System.Threading;
using System.Collections.Concurrent;

namespace RoboRun
{
    class Prompt
    {
        public static async void showBlackOverlay(Image BlackOverlay, float width, float height, float offset)
        {
            BlackOverlay.Opacity = 0;
            BlackOverlay.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/blackoverlay.png", UriKind.Absolute
                   ));
            BlackOverlay.Width = width;
            BlackOverlay.Height = height;
            BlackOverlay.Margin = new Thickness(0, offset, 0, 0);
            double i = 0;
            while (i < 1) //Continually increases opacity of logo
            {
                BlackOverlay.Opacity = i;
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(3));
                i += 0.04;
            }
        }

        public static async void showRedBlock(Image RedBlock, float width, float height, float offset, Image TextPrompt, Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, TextBox StraightTextEntry)
        {
            RedBlock.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/redblock.png", UriKind.Absolute
                   ));
            RedBlock.Width = 1920 * width / 1920;
            RedBlock.Height = 591 * height / 1080;
            RedBlock.Margin = new Thickness(width, offset + 245 * height / 1080, 0, 0);
            double j = width;
            while (j >= -2)
            {
                RedBlock.Margin = new Thickness(j, offset + 245 * height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j -= 20;
            }
            showTextPrompt(TextPrompt,width,height,offset, StraightTextEntry);
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(200));
            showPromptButtons(PromptBack, PromptForward,BackViewBox,ForwardViewBox,confirmLabel,exitLabel,height,width,offset);
            StraightTextEntry.IsReadOnly = false;
        }

        //take red block animation into a seperate method
        public static async void showRedBlockIfStatement(Image RedBlock, Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image ifPromptTitle, Image ifPrompt1st, Image ifPrompt2nd, ComboBox IfStatementComboBox, TextBox IfTextEntry)
        {
            await RedBlockAnimation(RedBlock);
            showIfPrompt(PromptBack, PromptForward, BackViewBox, ForwardViewBox, confirmLabel, exitLabel, ifPromptTitle, ifPrompt1st, ifPrompt2nd, IfStatementComboBox, IfTextEntry);
        }

        public static async void showRedBlockForLoop(Image RedBlock, Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image forPromptTitle, Image forPrompt1st, Image forPrompt2nd, TextBox forTextEntry)
        {
            await RedBlockAnimation(RedBlock);
            showForLoopPrompt(PromptBack, PromptForward, BackViewBox, ForwardViewBox, confirmLabel, exitLabel, forPromptTitle, forPrompt1st, forPrompt2nd, forTextEntry);
        }

        private static void showForLoopPrompt(Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image forPromptTitle, Image forPrompt1st, Image forPrompt2nd, TextBox forTextEntry)
        {
            PromptBack.Opacity = 1;
            PromptBack.IsHitTestVisible = true;
            BackViewBox.Margin = new Thickness(-650 * GameplayScreen.width / 1920, GameplayScreen.offset + 400 * GameplayScreen.height / 1080, 900 * GameplayScreen.width / 1920, 200 * GameplayScreen.height / 1080);
            PromptForward.Opacity = 1;
            PromptForward.IsHitTestVisible = true;
            ForwardViewBox.Margin = new Thickness(1360 * GameplayScreen.width / 1920, GameplayScreen.offset + 390 * GameplayScreen.height / 1080, -220 * GameplayScreen.width / 1920, 260 * GameplayScreen.height / 1080);

            confirmLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/confirmlabel.png", UriKind.Absolute
             ));
            confirmLabel.Height = 33 * GameplayScreen.height / 1080;
            confirmLabel.Width = 215 * GameplayScreen.width / 1920;
            confirmLabel.Margin = new Thickness(1675 * GameplayScreen.width / 1920, (GameplayScreen.offset / 3) + 650 * GameplayScreen.height / 1080, 0, 0);
            exitLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/exitlabel.png", UriKind.Absolute
               ));
            exitLabel.Height = 30 * GameplayScreen.height / 1080;
            exitLabel.Width = 95 * GameplayScreen.width / 1920;
            exitLabel.Margin = new Thickness(130 * GameplayScreen.width / 1920, (GameplayScreen.offset / 3) + 650 * GameplayScreen.height / 1080, 0, 0);

            forPromptTitle.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/forloopprompttitle.png", UriKind.Absolute
           ));
            forPromptTitle.Height = 118 * GameplayScreen.height / 1080;
            forPromptTitle.Width = 1206 * GameplayScreen.width / 1920;
            forPromptTitle.Margin = new Thickness(400 * GameplayScreen.width / 1920, 277 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            forPrompt1st.Height = 65 * GameplayScreen.height / 800;
            forPrompt1st.Width = 125 * GameplayScreen.width / 1280;
            forPrompt1st.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/forpromptfirst.png", UriKind.Absolute
            ));
            forPrompt1st.Margin = new Thickness(200 * GameplayScreen.width / 1280, 430 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            forTextEntry.Opacity = 1;
            forTextEntry.IsEnabled = true;
            forTextEntry.Width = 250 * GameplayScreen.width / 1920;
            forTextEntry.MaxLength = 1;
            forTextEntry.Height = 150 * GameplayScreen.height / 1080;
            forTextEntry.Margin = new Thickness(550 * GameplayScreen.width / 1920, GameplayScreen.offset + 400 * GameplayScreen.height / 1080, 0, 0);
            forTextEntry.FontStyle = Windows.UI.Text.FontStyle.Oblique;
            forTextEntry.FontSize = GameplayScreen.height / 20 * 2.2;
            forTextEntry.TextAlignment = TextAlignment.Center;

            forPrompt2nd.Height = 70 * GameplayScreen.height / 800;
            forPrompt2nd.Width = 500 * GameplayScreen.width / 1280;
            forPrompt2nd.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/forpromptsecond.png", UriKind.Absolute
            ));
            forPrompt2nd.Margin = new Thickness(570  * GameplayScreen.width / 1280, 435 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);


        }

        private static async System.Threading.Tasks.Task RedBlockAnimation(Image RedBlock)
        {
            RedBlock.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/redblock.png", UriKind.Absolute
                  ));
            RedBlock.Width = 1920 * GameplayScreen.width / 1920;
            RedBlock.Height = 591 * GameplayScreen.height / 1080;
            RedBlock.Margin = new Thickness(GameplayScreen.width, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
            double j = GameplayScreen.width;
            while (j >= -2)
            {
                RedBlock.Margin = new Thickness(j, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j -= 20;
            }
        }

        public static async void showRedBlockWhileLoop(Image RedBlock, Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image whilePromptTitle, Image whilePrompt1st, Image whilePrompt2nd, TextBox whileTextEntry, ComboBox whileComboBox)
        {
            await RedBlockAnimation(RedBlock);
            showWhileLoopPrompt(PromptBack, PromptForward, BackViewBox, ForwardViewBox, confirmLabel, exitLabel, whilePromptTitle, whilePrompt1st, whilePrompt2nd, whileTextEntry, whileComboBox);
        }

        private static void showWhileLoopPrompt(Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image whilePromptTitle, Image whilePrompt1st, Image whilePrompt2nd, TextBox whileTextEntry, ComboBox whileComboBox)
        {
            PromptBack.Opacity = 1;
            PromptBack.IsHitTestVisible = true;
            BackViewBox.Margin = new Thickness(-650 * GameplayScreen.width / 1920, GameplayScreen.offset + 400 * GameplayScreen.height / 1080, 900 * GameplayScreen.width / 1920, 200 * GameplayScreen.height / 1080);
            PromptForward.Opacity = 1;
            PromptForward.IsHitTestVisible = true;
            ForwardViewBox.Margin = new Thickness(1360 * GameplayScreen.width / 1920, GameplayScreen.offset + 390 * GameplayScreen.height / 1080, -220 * GameplayScreen.width / 1920, 260 * GameplayScreen.height / 1080);

            whilePromptTitle.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/whileloopprompttitle.png", UriKind.Absolute
            ));
            whilePromptTitle.Height = 118 * GameplayScreen.height / 1080;
            whilePromptTitle.Width = 1206 * GameplayScreen.width / 1920;
            whilePromptTitle.Margin = new Thickness(373 * GameplayScreen.width / 1920, 273 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            whilePrompt1st.Height = 72 * GameplayScreen.height / 1080;
            whilePrompt1st.Width = 718 * GameplayScreen.width / 1920;
            whilePrompt1st.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/whilepromptfirst.png", UriKind.Absolute
            ));
            whilePrompt1st.Margin = new Thickness(280 * GameplayScreen.width / 1920, 406 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            whilePrompt2nd.Height = 74 * GameplayScreen.height / 1080;
            whilePrompt2nd.Width = 381 * GameplayScreen.width / 1920;
            whilePrompt2nd.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/whilepromptsecond.png", UriKind.Absolute
            ));
            whilePrompt2nd.Margin = new Thickness(750 * GameplayScreen.width / 1920, 585 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            whileComboBox.HorizontalContentAlignment = HorizontalAlignment.Center;
            whileComboBox.IsEnabled = true;
            whileComboBox.Opacity = 1;
            whileComboBox.Height = 100 * GameplayScreen.height / 1080;
            whileComboBox.Width = 600 * GameplayScreen.width / 1920;
            whileComboBox.FontSize = GameplayScreen.height / 30;
            whileComboBox.Margin = new Thickness(675 * GameplayScreen.width / 1280, 290 * GameplayScreen.height / 800 + GameplayScreen.offset, 0, 0);

            whileTextEntry.Opacity = 1;
            whileTextEntry.IsEnabled = true;
            whileTextEntry.Width = 250 * GameplayScreen.width / 1920;
            whileTextEntry.MaxLength = 1;
            whileTextEntry.Height = 200 * GameplayScreen.height / 1080;
            whileTextEntry.Margin = new Thickness(460 * GameplayScreen.width / 1920, GameplayScreen.offset + 500 * GameplayScreen.height / 1080, 0, 0);
            whileTextEntry.FontStyle = Windows.UI.Text.FontStyle.Oblique;
            whileTextEntry.FontSize = GameplayScreen.height / 20 * 2.5;
            whileTextEntry.TextAlignment = TextAlignment.Center;

            confirmLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/confirmlabel.png", UriKind.Absolute
             ));
            confirmLabel.Height = 33 * GameplayScreen.height / 1080;
            confirmLabel.Width = 215 * GameplayScreen.width / 1920;
            confirmLabel.Margin = new Thickness(1675 * GameplayScreen.width / 1920, (GameplayScreen.offset / 3) + 650 * GameplayScreen.height / 1080, 0, 0);
            exitLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/exitlabel.png", UriKind.Absolute
               ));
            exitLabel.Height = 30 * GameplayScreen.height / 1080;
            exitLabel.Width = 95 * GameplayScreen.width / 1920;
            exitLabel.Margin = new Thickness(130 * GameplayScreen.width / 1920, (GameplayScreen.offset / 3) + 650 * GameplayScreen.height / 1080, 0, 0);
        }
        public static async void showRedBlockGameOver(Image RedBlock, float width, float height, float offset, Image TextPrompt, Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel)
        
        {
            //rename method to indicate it serves both game over and win prompts
            RedBlock.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/redblock.png", UriKind.Absolute
                   ));
            RedBlock.Width = 1920 * GameplayScreen.width / 1920;
            RedBlock.Height = 591 * GameplayScreen.height / 1080;
            RedBlock.Margin = new Thickness(GameplayScreen.width, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
            double j = GameplayScreen.width;
            while (j >= -2)
            {
                RedBlock.Margin = new Thickness(j, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j -= 20;
            }
            if (GameplayScreen.commandExecuted.Contains("Game Over"))
            {
                showGameOverTextPrompt(TextPrompt);
                showGameOverPromptButtons(PromptBack, PromptForward, BackViewBox, ForwardViewBox, confirmLabel, exitLabel, height, width, offset);
            }
            else
            {
                showYouWonTextPrompt(TextPrompt);
                showYouWonTextPromptButtons(PromptBack, PromptForward, BackViewBox, ForwardViewBox, confirmLabel, exitLabel, height, width, offset);
            }

        }

        public async static void showRedBlockYouWin(Image RedBlock, float width, float height, float offset, Image TextPrompt, Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image touchDevelop, Image touchDevelopText)
        {
            showRedBlockGameOver(RedBlock, width, height, offset, TextPrompt, PromptBack, PromptForward, BackViewBox, ForwardViewBox, confirmLabel, exitLabel);
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1000));
            touchDevelop.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/touchdevelopbutton.png", UriKind.Absolute
                  ));
            touchDevelop.Height = 190 * height / 800;
            touchDevelop.Width = 190 * width / 1280;

            touchDevelop.Margin = new Thickness(0, 64 * height / 1080 + offset, 50 * width / 1920, 0);

            touchDevelopText.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/touchdeveloplabel.png", UriKind.Absolute
                  ));
            touchDevelopText.Height = 81 * height / 800;
            touchDevelopText.Width = 236 * width / 1280;

            touchDevelopText.Margin = new Thickness(0, 420 * height / 1080 + offset, 46 * width / 1920, 0);  
        }
        private static void showYouWonTextPrompt(Image TextPrompt)
        {
            TextPrompt.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/youwinprompt.png", UriKind.Absolute
                  ));
            TextPrompt.Width = 1716 * GameplayScreen.width / 1920;
            TextPrompt.Height = 77 * GameplayScreen.height / 1080;
            TextPrompt.Margin = new Thickness(100 * GameplayScreen.width / 1920, GameplayScreen.offset + 290 * GameplayScreen.height / 1080, 0, 0);
        }

        private static void showGameOverPromptButtons(Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, float height, float width, float offset)
        {
            PromptBack.Opacity = 1;
            PromptBack.IsHitTestVisible = true;
            BackViewBox.Margin = new Thickness(0, offset + 400 * height / 1080, 900 * width / 1920, 0);
            PromptForward.Opacity = 1;
            PromptForward.IsHitTestVisible = true;
            ForwardViewBox.Margin = new Thickness(830 * width / 1920, offset + 380 * height / 1080, 0, 110 * height / 1080);
            confirmLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/tryagainlabel.png", UriKind.Absolute
               ));
            confirmLabel.Height = 53 * height / 1080;
            confirmLabel.Width = 236 * width / 1920;
            confirmLabel.Margin = new Thickness(1270 * width / 1920, (offset / 3) + 735 * height / 1080, 0, 0);
            exitLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/exitlabel.png", UriKind.Absolute
               ));
            exitLabel.Height = 50 * height / 1080;
            exitLabel.Width = 115 * width / 1920;
            exitLabel.Margin = new Thickness(427 * width / 1920, (offset / 3) + 750 * height / 1080, 0, 0);
        }

        private static void showYouWonTextPromptButtons(Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, float height, float width, float offset)
        {
            PromptBack.Opacity = 1;
            PromptBack.IsHitTestVisible = true;
            BackViewBox.Margin = new Thickness(0, offset + 400 * height / 1080, 900 * width / 1920, 0);
            PromptForward.Opacity = 1;
            PromptForward.IsHitTestVisible = true;
            ForwardViewBox.Margin = new Thickness(830 * width / 1920, offset + 380 * height / 1080, 0, 110 * height / 1080);
            confirmLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/tryagainlabel.png", UriKind.Absolute
               ));
            confirmLabel.Height = 53 * height / 1080;
            confirmLabel.Width = 236 * width / 1920;
            confirmLabel.Margin = new Thickness(1270 * width / 1920, (offset / 3) + 735 * height / 1080, 0, 0);
            exitLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/exitlabel.png", UriKind.Absolute
               ));
            exitLabel.Height = 50 * height / 1080;
            exitLabel.Width = 115 * width / 1920;
            exitLabel.Margin = new Thickness(427 * width / 1920, (offset / 3) + 750 * height / 1080, 0, 0);
        }

        private static void showGameOverTextPrompt(Image TextPrompt)
        {
            if (GameplayScreen.commandExecuted.Equals("Game Over Wall"))
            {
                TextPrompt.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/gameoverwallprompt.png", UriKind.Absolute
                   ));
                TextPrompt.Width = 1716 * GameplayScreen.width / 1920;
                TextPrompt.Height = 77 * GameplayScreen.height / 1080;
                TextPrompt.Margin = new Thickness(100 * GameplayScreen.width / 1920, GameplayScreen.offset + 290 * GameplayScreen.height / 1080, 0, 0);
            }
            else if (GameplayScreen.commandExecuted.Equals("Game Over Obstacle"))
            {
                TextPrompt.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/gameoverobstacleprompt.png", UriKind.Absolute
                   ));
                TextPrompt.Width = 1716 * GameplayScreen.width / 1920;
                TextPrompt.Height = 77 * GameplayScreen.height / 1080;
                TextPrompt.Margin = new Thickness(100 * GameplayScreen.width / 1920, GameplayScreen.offset + 290 * GameplayScreen.height / 1080, 0, 0);
            }
            else if (GameplayScreen.commandExecuted.Equals("Game Over End Of Queue"))
            {
                TextPrompt.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/gameoverendofqueue.png", UriKind.Absolute
                   ));
                TextPrompt.Width = 1716 * GameplayScreen.width / 1920;
                TextPrompt.Height = 77 * GameplayScreen.height / 1080;
                TextPrompt.Margin = new Thickness(100 * GameplayScreen.width / 1920, GameplayScreen.offset + 290 * GameplayScreen.height / 1080, 0, 0);
            }
        }

        private static void showTextPrompt(Image TextPrompt,float width, float height, float offset, TextBox StraightTextEntry)
        { //Different Prompts for different commands.
            if (GameplayScreen.commandExecuted.Contains("Go Straight"))
            {
                TextPrompt.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/straightprompt.png", UriKind.Absolute
                   ));
                TextPrompt.Width = 1716 * width / 1920;
                TextPrompt.Height = 77 * height / 1080;
                TextPrompt.Margin = new Thickness(100 * width / 1920, offset + 290 * height / 1080, 0, 0);
                showStraightTextBoxEntry(StraightTextEntry,width,height,offset);
            }
            if (GameplayScreen.commandExecuted.Equals("Play"))
            {
                TextPrompt.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/playprompt.png", UriKind.Absolute
                 ));
                TextPrompt.Width = 1716 * width / 1920;
                TextPrompt.Height = 77 * height / 1080;
                TextPrompt.Margin = new Thickness(100 * width / 1920, offset + 290 * height / 1080, 0, 0);
            }
           
        }

        private static void showIfPrompt(Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, Image ifPromptTitle, Image ifPrompt1st, Image ifPrompt2nd, ComboBox ifStatementComboBox, TextBox ifTextEntry)
        {
            PromptBack.Opacity = 1;
            PromptBack.IsHitTestVisible = true;
            BackViewBox.Margin = new Thickness(-650 * GameplayScreen.width / 1920, GameplayScreen.offset + 400 * GameplayScreen.height / 1080, 900 * GameplayScreen.width / 1920, 200 * GameplayScreen.height / 1080);
            PromptForward.Opacity = 1;
            PromptForward.IsHitTestVisible = true;
            ForwardViewBox.Margin = new Thickness(1360 * GameplayScreen.width / 1920, GameplayScreen.offset + 390 * GameplayScreen.height / 1080, -220 * GameplayScreen.width / 1920, 260 * GameplayScreen.height / 1080);
            ifPromptTitle.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/ifprompttitle.png", UriKind.Absolute
            ));
            ifPromptTitle.Height = 118 * GameplayScreen.height / 1080;
            ifPromptTitle.Width = 1206 * GameplayScreen.width / 1920;
            ifPromptTitle.Margin = new Thickness(373 * GameplayScreen.width / 1920, 277 * GameplayScreen.height/1080 + GameplayScreen.offset, 0, 0);
            
            ifPrompt1st.Height = 72 * GameplayScreen.height / 1080;
            ifPrompt1st.Width = 540 * GameplayScreen.width / 1920;
            ifPrompt1st.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/ifpromptfirst.png", UriKind.Absolute
            ));
            ifPrompt1st.Margin = new Thickness(360 * GameplayScreen.width / 1920, 406 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            ifPrompt2nd.Height = 74 * GameplayScreen.height / 1080;
            ifPrompt2nd.Width = 381 * GameplayScreen.width / 1920;
            ifPrompt2nd.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/ifpromptsecond.png", UriKind.Absolute
            ));
            ifPrompt2nd.Margin = new Thickness(750 * GameplayScreen.width / 1920, 585 * GameplayScreen.height / 1080 + GameplayScreen.offset, 0, 0);

            ifStatementComboBox.HorizontalContentAlignment = HorizontalAlignment.Center;
            ifStatementComboBox.IsEnabled = true;
            ifStatementComboBox.Opacity = 1;
            ifStatementComboBox.Height = 100 * GameplayScreen.height / 1080;
            ifStatementComboBox.Width = 600 * GameplayScreen.width / 1920;
            ifStatementComboBox.FontSize = GameplayScreen.height/30;
            ifStatementComboBox.Margin = new Thickness(650 * GameplayScreen.width / 1280, 290 * GameplayScreen.height / 800 + GameplayScreen.offset, 0, 0);

            ifTextEntry.Opacity = 1;
            ifTextEntry.IsEnabled = true;
            ifTextEntry.Width = 250 * GameplayScreen.width / 1920;
            ifTextEntry.MaxLength = 1;
            ifTextEntry.Height = 200 * GameplayScreen.height / 1080;
            ifTextEntry.Margin = new Thickness(460 * GameplayScreen.width / 1920, GameplayScreen.offset + 500 * GameplayScreen.height / 1080, 0, 0);
            ifTextEntry.FontStyle = Windows.UI.Text.FontStyle.Oblique;
            ifTextEntry.FontSize = GameplayScreen.height/20 * 2.5;
            ifTextEntry.TextAlignment = TextAlignment.Center;
            confirmLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/confirmlabel.png", UriKind.Absolute
             ));
            confirmLabel.Height = 33 * GameplayScreen.height / 1080;
            confirmLabel.Width = 215 * GameplayScreen.width / 1920;
            confirmLabel.Margin = new Thickness(1675 * GameplayScreen.width / 1920, (GameplayScreen.offset / 3) + 650 * GameplayScreen.height / 1080, 0, 0);
            exitLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/exitlabel.png", UriKind.Absolute
               ));
            exitLabel.Height = 30 * GameplayScreen.height / 1080;
            exitLabel.Width = 95 * GameplayScreen.width / 1920;
            exitLabel.Margin = new Thickness(130 * GameplayScreen.width / 1920, (GameplayScreen.offset / 3) + 650 * GameplayScreen.height / 1080, 0, 0);
        }

        private static void showPromptButtons(Button PromptBack, Button PromptForward, Viewbox BackViewBox, Viewbox ForwardViewBox, Image confirmLabel, Image exitLabel, float height, float width, float offset)
        {
            if (GameplayScreen.commandExecuted.Contains("Go Straight") || GameplayScreen.commandExecuted.Equals("Play"))
            {
                PromptBack.Opacity = 1;
                PromptBack.IsHitTestVisible = true;
                BackViewBox.Margin = new Thickness(0, offset + 400 * height / 1080, 900 * width / 1920, 0);
                PromptForward.Opacity = 1;
                PromptForward.IsHitTestVisible = true;
                ForwardViewBox.Margin = new Thickness(830 * width / 1920, offset + 380 * height / 1080, 0, 110 * height / 1080);
                confirmLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/confirmlabel.png", UriKind.Absolute
                   ));
                confirmLabel.Height = 53 * height / 1080;
                confirmLabel.Width = 236 * width / 1920;
                confirmLabel.Margin = new Thickness(1270 * width / 1920, (offset / 3) + 735 * height / 1080, 0, 0);
                exitLabel.Source = new BitmapImage(new Uri("ms-appx:///Assets/GameplayScreen/exitlabel.png", UriKind.Absolute
                   ));
                exitLabel.Height = 50 * height / 1080;
                exitLabel.Width = 115 * width / 1920;
                exitLabel.Margin = new Thickness(427 * width / 1920, (offset / 3) + 750 * height / 1080, 0, 0);
            }
        }

        private static void showStraightTextBoxEntry(TextBox StraightTextEntry,float width, float height, float offset)
        {
            StraightTextEntry.Opacity = 1;
            StraightTextEntry.IsEnabled = true;
            StraightTextEntry.Width = 360 * width / 1920;
            StraightTextEntry.MaxLength = 1;
            StraightTextEntry.Height = 380 * height / 1080;
            StraightTextEntry.Margin = new Thickness(760 * width / 1920, offset + 380 * height / 1080, 0, 0);
            StraightTextEntry.FontStyle = Windows.UI.Text.FontStyle.Oblique;
            StraightTextEntry.FontSize = 200;
        }

        public static async void returnToGameplayFromPrompt(Button PromptBack, Button PromptForward, String commandExecuted, TextBox StraightTextEntry, Image confirmLabel, Image exitLabel, Image TextPrompt, float width, float height, float offset, Image RedBlock, Image BlackOverlay, Button button)
        {
            PromptBack.Opacity = 0;
            PromptBack.IsHitTestVisible = false;
            PromptForward.Opacity = 0;
            PromptForward.IsHitTestVisible = false;
            if (commandExecuted.Contains("Go Straight") || commandExecuted.Contains ("If Statement"))
            {
                StraightTextEntry.Opacity = 0;
                StraightTextEntry.Height = 0;
                StraightTextEntry.Width = 0;
                StraightTextEntry.IsEnabled = false;
                button.IsEnabled = true;
            }
            confirmLabel.Source = null;
            exitLabel.Source = null;
            TextPrompt.Source = null;
            double j = 0;
            while (j <= width)
            {
                RedBlock.Margin = new Thickness(j, offset + 245 * height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j += 30;
            }
            RedBlock.Source = null;
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
            double i = 1;
            while (i >= 0)
            {
                BlackOverlay.Opacity = i;
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(10));
                i -= 0.04;
            }
            BlackOverlay.Source = null;
            //commandExecuted = null;
        }

        public static async void returnToGameplayFromForLoop(Button button, Button PromptBack, Button PromptForward, String commandExecuted, Image confirmLabel, Image exitLabel, Image RedBlock, Image BlackOverlay, Image forPromptTitle, Image forPrompt1st, Image forPrompt2nd, TextBox forTextEntry)
        {
            PromptBack.Opacity = 0;
            PromptBack.IsHitTestVisible = false;
            PromptForward.Opacity = 0;
            PromptForward.IsHitTestVisible = false;
            forTextEntry.Opacity = 0;
            forTextEntry.IsEnabled = false;
            forTextEntry.Height = 0;
            forTextEntry.Width = 0;
            forPrompt1st.Source = null;
            forPrompt2nd.Source = null;
            confirmLabel.Source = null;
            exitLabel.Source = null;
            forPromptTitle.Source = null;
            double j = 0;
            while (j <= GameplayScreen.width)
            {
                RedBlock.Margin = new Thickness(j, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j += 30;
            }
            RedBlock.Source = null;
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
            double i = 1;
            while (i >= 0)
            {
                BlackOverlay.Opacity = i;
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(10));
                i -= 0.04;
            }
            BlackOverlay.Source = null;
            button.IsEnabled = true;


        }

        
        public static async void returnToGameplayFromPromptIfStatement(Button button, Button PromptBack, Button PromptForward, String commandExecuted, Image confirmLabel, Image exitLabel, Image RedBlock, Image BlackOverlay, Image ifPromptTitle, Image ifPrompt1st, Image ifPrompt2nd, ComboBox ifStatementComboBox, TextBox ifTextEntry)
        {
            PromptBack.Opacity = 0;
            PromptBack.IsHitTestVisible = false;
            PromptForward.Opacity = 0;
            PromptForward.IsHitTestVisible = false;
            ifTextEntry.Opacity = 0;
            ifTextEntry.IsEnabled = false;
            ifTextEntry.Height = 0;
            ifTextEntry.Width = 0;
            ifPrompt1st.Source = null;
            ifPrompt2nd.Source = null;
            ifStatementComboBox.IsEnabled = false;
            ifStatementComboBox.Height = 0;
            ifStatementComboBox.Width = 0;
            confirmLabel.Source = null;
            exitLabel.Source = null;
            ifPromptTitle.Source = null;
            double j = 0;
            while (j <= GameplayScreen.width)
            {
                RedBlock.Margin = new Thickness(j, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j += 30;
            }
            RedBlock.Source = null;
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
            double i = 1;
            while (i >= 0)
            {
                BlackOverlay.Opacity = i;
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(10));
                i -= 0.04;
            }
            BlackOverlay.Source = null;
            button.IsEnabled = true;
            
        }

        public static async void returnToGameplayFromWhileLoop(Button button, Button PromptBack, Button PromptForward, String commandExecuted, Image confirmLabel, Image exitLabel, Image RedBlock, Image BlackOverlay, Image ifPromptTitle, Image ifPrompt1st, Image ifPrompt2nd, ComboBox ifStatementComboBox, TextBox ifTextEntry)
        {
            PromptBack.Opacity = 0;
            PromptBack.IsHitTestVisible = false;
            PromptForward.Opacity = 0;
            PromptForward.IsHitTestVisible = false;
            ifTextEntry.Opacity = 0;
            ifTextEntry.IsEnabled = false;
            ifTextEntry.Height = 0;
            ifTextEntry.Width = 0;
            ifPrompt1st.Source = null;
            ifPrompt2nd.Source = null;
            ifStatementComboBox.IsEnabled = false;
            ifStatementComboBox.Height = 0;
            ifStatementComboBox.Width = 0;
            confirmLabel.Source = null;
            exitLabel.Source = null;
            ifPromptTitle.Source = null;
            double j = 0;
            while (j <= GameplayScreen.width)
            {
                RedBlock.Margin = new Thickness(j, GameplayScreen.offset + 245 * GameplayScreen.height / 1080, 0, 0);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(1));
                j += 30;
            }
            RedBlock.Source = null;
            await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));
            double i = 1;
            while (i >= 0)
            {
                BlackOverlay.Opacity = i;
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(10));
                i -= 0.04;
            }
            BlackOverlay.Source = null;
          
            button.IsEnabled = true;
        }
        
        //used for go straight and play
        public static void promptSubmission(String commandExecuted, String goStraightEntry, TextBox StraightTextEntry, Button PromptBack, Button PromptForward, Image confirmLabel, Image exitLabel, Image TextPrompt, float width, float height, float offset, Image BlackOverlay, Button GoStraightButton, Image RedBlock, TextBlock commandQueueTextBlock, ScrollViewer commandQueueScrollViewer, Image Countdown)
        {
            if (commandExecuted.Equals("Play"))
            {
                Prompt.returnToGameplayFromPrompt(PromptBack, PromptForward, commandExecuted, StraightTextEntry, confirmLabel, exitLabel, TextPrompt, width, height, offset, RedBlock, BlackOverlay, GoStraightButton);
                PrepareToPlay.prepareToPlay(Countdown, height, width, offset, commandQueueTextBlock);
            }
            else if (commandExecuted.Contains("If Statement"))
            {
                goStraightEntry = StraightTextEntry.Text;
                double num;
                bool isNum = double.TryParse(goStraightEntry, out num);
                if (isNum) //checks if entry is a number or not
                {
                    if (goStraightEntry.Equals("1"))
                    {
                        CommandQueue.addToCommandQueue(("\tGo Straight " + goStraightEntry + " square"), commandQueueTextBlock, commandQueueScrollViewer);
                    }
                    else
                    {
                        CommandQueue.addToCommandQueue(("\tGo Straight " + goStraightEntry + " squares"), commandQueueTextBlock, commandQueueScrollViewer);
                    }
                    Prompt.returnToGameplayFromPrompt(PromptBack, PromptForward, commandExecuted, StraightTextEntry, confirmLabel, exitLabel, TextPrompt, width, height, offset, RedBlock, BlackOverlay, GoStraightButton);
                }
                else
                {
                    goStraightEntry = null;
                }
            }
            else if (GameplayScreen.formarker == true || GameplayScreen.whilemarker == true)
            {
                goStraightEntry = StraightTextEntry.Text;
                double num;
                bool isNum = double.TryParse(goStraightEntry, out num);
                if (isNum) //checks if entry is a number or not
                {
                    if (goStraightEntry.Equals("1"))
                    {

                        CommandQueue.addToCommandQueue(("   Go Straight " + goStraightEntry + " square"), commandQueueTextBlock, commandQueueScrollViewer);

                    }
                    else
                    {

                        CommandQueue.addToCommandQueue(("   Go Straight " + goStraightEntry + " squares"), commandQueueTextBlock, commandQueueScrollViewer);

                    }
                    Prompt.returnToGameplayFromPrompt(PromptBack, PromptForward, commandExecuted, StraightTextEntry, confirmLabel, exitLabel, TextPrompt, width, height, offset, RedBlock, BlackOverlay, GoStraightButton);
                }
                else
                {
                    goStraightEntry = null;
                }
            }
            
            else if (commandExecuted.Contains("Go Straight"))
            {
                goStraightEntry = StraightTextEntry.Text;
                double num;
                bool isNum = double.TryParse(goStraightEntry, out num);
                if (isNum) //checks if entry is a number or not
                {
                    GameplayScreen.commandCounter++;
                    if (goStraightEntry.Equals("1"))
                    {
                        if (GameplayScreen.commandExecuted.Contains("If Statement"))
                        {
                            CommandQueue.addToCommandQueue(("\tGo Straight " + goStraightEntry + " square"), commandQueueTextBlock, commandQueueScrollViewer);
                        }
                        else
                        {
                            CommandQueue.addToCommandQueue((GameplayScreen.commandCounter + ". " + "Go Straight " + goStraightEntry + " square"), commandQueueTextBlock, commandQueueScrollViewer);
                        }
                    }
                    else
                    {
                        if (GameplayScreen.commandExecuted.Contains("If Statement"))
                        {
                            CommandQueue.addToCommandQueue(("\tGo Straight " + goStraightEntry + " squares"), commandQueueTextBlock, commandQueueScrollViewer);
                        }
                        else
                        {
                            CommandQueue.addToCommandQueue((GameplayScreen.commandCounter + ". " + "Go Straight " + goStraightEntry + " squares"), commandQueueTextBlock, commandQueueScrollViewer);
                        }
                    }
                    Prompt.returnToGameplayFromPrompt(PromptBack, PromptForward, commandExecuted, StraightTextEntry, confirmLabel, exitLabel, TextPrompt, width, height, offset, RedBlock, BlackOverlay, GoStraightButton);
                }
                else
                {
                    goStraightEntry = null;
                }
            }
            
   
        }
    }
}
